# Contributor: Mathias LANG <pro.mathias.lang@gmail.com>
# Maintainer: Mathias LANG <pro.mathias.lang@gmail.com>
pkgname=dub
pkgver=1.34.0
pkgrel=1
pkgdesc="Package and build management system for D"
url="https://code.dlang.org/"
arch="x86_64 aarch64"
license="MIT"
depends="libcurl"
makedepends="chrpath ldc bash curl-dev"
subpackages="$pkgname-zsh-completion $pkgname-doc"
source="$pkgname-$pkgver.tar.gz::https://github.com/dlang/dub/archive/v$pkgver.tar.gz"

build() {
	# The build script needs a DMD-like interface to pass its arguments, so use ldmd2
	DMD=ldmd2 GITVER="v$pkgver" ldc2 -run "$builddir/build.d"

	# Build man pages
	"$builddir/bin/dub" --compiler=ldc2 --single scripts/man/gen_man.d

	# Remove redundant rpath
	chrpath -d "$builddir/bin/dub"
}

check() {
	bin/dub test --compiler=ldc2
}

package() {
	install -s -D "$builddir/bin/dub" "$pkgdir/usr/bin/dub"
	install -Dm644 "$builddir/scripts/zsh-completion/_dub" "$pkgdir/usr/share/zsh/site-functions/_dub"
	mkdir -p "$pkgdir/usr/share/man/man1/"
	cp "$builddir"/scripts/man/*.1 "$pkgdir/usr/share/man/man1/"
}

sha512sums="
24ed9f328debf8d921061a8d898bfc80c023864d8c525b61353c9de9cf33de2e2189cfa845e85553fc902c889dd3538b64320f3003eda0113d2c3c9a2be881f0  dub-1.34.0.tar.gz
"
